<?php
session_start(); 
// Connect to the Database
include("includes/connect.php");
include("functions/registration_functions.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/Main-Template.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Star Map Mobile</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #CCCCCC}
-->
</style>
</head>

<body class="oneColFixCtrHdr">

<div id="container">
  <div id="header"><a href="index.php">home</a> | <a href="http://www.bmcstudiosllc.com/starmap/forum/">forum</a> | <a href="news.php">news</a> | <a href="download.php">download</a> | <a href="account.php">account</a> | <a href="register.php">register</a>
    <!-- end #header -->
  </div>
  <div id="mainContent">
    <table width="100%" border="1" bordercolor="#DDDDDD" cellpadding="10" bgcolor="#333333">
  <tr>
    <td width="750" height="200"><div align="center"><img src="images/smmbanner.png" alt="smm" width="750" height="200"></div></td>
  </tr>
  <tr>
    <td height="100" width="750"><div align="center" class="style1">
      <p>Developed by University of Miami Undergraduate Students</p>
        <p>Joey Kadin, Brandon Calabro, Mychal Sligh, Alex Alvarez</p>
      </div></td>
  </tr>
  <tr>
    <td><!-- InstanceBeginEditable name="MainContent" -->
<?php if(isset($_SESSION['USER'])){ 

include("functions/user_functions.php");

?>
<div align="center" class="NewsHeading">Change Email</div>

<br> 

<div align="center" class="UserTableFont">

<form action="changeemail.php" method="POST"> 
<table width="75%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td width="50%">Current Email:</td>
    <td width="50%"><input type="text" name="currEmail" size="50"></td>
  </tr>
  <tr>
    <td>New Email:</td>
    <td><input type="text" name="newEmail" size="50"></td>
  </tr>
  <tr>
    <td colspan="2"><div align="center"><input type="hidden" value="1" name="EMAIL_FLAG" /><input type="submit" name="submit" value="Change Email" /></div></td>
    </tr>
</table>
</form>
</div>
<br>
<p><a href="memberpanel.php">Back to Member Panel</a></p>
<?php
	if($_POST['EMAIL_FLAG'] == 1)
	{
		$newEmail = $_POST['newEmail'];
		$username = $_SESSION['USER'];
		if($uEmail == $_POST['currEmail']) 
		{ 
			mysql_query("UPDATE `user_table` SET `email` = '$newEmail' WHERE `username` = '$username'"); 
		 	print "<font color='#FF0000'>Email has been changed!</font><br>";
		}
		else { print "<font color='#FF0000'>Current Email is incorrect.</font><br>"; }
		
	}
?>

<?php } else {

     	   // This will redirect the user to the index page where they must log in again!
 	   
 	   print "<p>User is NOT Authentic</p>";  
 	   print "<p>Redirecting...</p>";      
       // This will refresh the page with the new session started
       print "<META HTTP-EQUIV = 'Refresh' Content = '2; URL =index.php'>";  // May need a slash in front of index.php

}
?>

    <!-- InstanceEndEditable --></td>
  </tr>
</table>

	<!-- end #mainContent --></div>
  <div id="footer">
    <p>All rights reserved. Powered by <a href="http://www.bmcstudiosllc.com/">BMC Studios LLC.</a></p>
  <!-- end #footer --></div>
<!-- end #container --></div>
</body>
<!-- InstanceEnd --></html>
